FROM golang:1.18-alpine
ENV GO111MODULE=on \
    GOPROXY=https://goproxy.cn,direct \
    CGO_ENABLED=0 \
    GOOS=linux \
    GOARCH=amd64
WORKDIR /opt
ADD .  /opt
COPY go.mod .
COPY go.sum .
RUN go mod download
RUN go build -o main ./main.go  
EXPOSE 8081
CMD ["/opt/main"]
